package com.lagou.sqlsession;

import com.lagou.pojo.Configuration;
import org.dom4j.DocumentException;

import java.beans.PropertyVetoException;
import java.io.InputStream;

public class SqlSessionFactoryBuilder {

    public  SqlSessionFactory builder(InputStream inputStream) throws DocumentException, PropertyVetoException {
        //1、使用jom4j解析配置文件，将解析出来的内容封装到configuartion对象中
        XmlConfigBuilder   xmlConfigBuilder= new XmlConfigBuilder();
        Configuration configuration = xmlConfigBuilder.parseConfig(inputStream);

        //2、创建SqlSessionFactory对象,工程类

        DefaultSqlSessionFactory defaultSqlSessionFactory = new DefaultSqlSessionFactory(configuration);

        return defaultSqlSessionFactory;
    }


}
